/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


var xmlHttp;
var objIDvat;
var objIDgrand;

function updatevat(val, serverPage, id1) {
	objIDvat = id1;
	xmlHttp = getXmlHttpRequest();
	if(xmlHttp==null) {
		alert("Browser tidak mendukung Ajax");
		return;
	}
	var url = serverPage;
	url = url+".do?step=updateVat&val="+val;
	url = url+"&sid="+Math.random();
        xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = stateChange;
        xmlHttp.send(null);        
}

function updategrandtotal(val, serverPage, id2) {
	xmlHttp = getXmlHttpRequest();
        objIDgrand = id2;
	if(xmlHttp==null) {
		alert("Browser tidak mendukung Ajax");
		return;
	}
	var url = serverPage;
	url = url+".do?step=updateGrandTotal&val="+val;
	url = url+"&sid="+Math.random();
        xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = stateChangeGrand;
        xmlHttp.send(null);
}

function getXmlHttpRequest() {
	xmlHttp = null;
	try {
		//Firefox, Opera, dll
		xmlHttp = new XMLHttpRequest();
	} catch(e) {
		try {
			//IE 6
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(E) {
			//IE 5.5 +
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function stateChange() {
    if(xmlHttp.readyState==4) {
        document.getElementById(objIDvat).innerHTML = xmlHttp.responseText;
    }
    else if(xmlHttp.readyState==3) {
        document.getElementById(objIDvat).innerHTML = "<font size=\"1\" face=\"Arial\">Updating...</font>";
    }
}

function stateChangeGrand() {
    if(xmlHttp.readyState==4) {
        document.getElementById(objIDgrand).innerHTML = xmlHttp.responseText;
    }
    else if(xmlHttp.readyState==3) {
        document.getElementById(objIDgrand).innerHTML = "<font size=\"1\" face=\"Arial\">Updating...</font>";
    }
}